<template>
  <div id="app">
    <div id="table" v-if="num">
      <el-table
        :data="tableData"
        stripe
        style="width: 100%"
        class="table"
        height="650"
        max-height="650"
        highlight-current-row
        v-loading="loading"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(0, 0, 0, 0.8)"
        id="out_table"
      >
        <el-table-column prop="time" label="时间" width="160">
        </el-table-column>

        <el-table-column prop="expedite" label="畅通比" width="160" sortable>
        </el-table-column>

        <el-table-column prop="congested" label="缓行比" width="160" sortable>
        </el-table-column>

        <el-table-column prop="blocked" label="拥堵比"> </el-table-column>
        <el-table-column prop="unknown" label="位置路段比"> </el-table-column>
        <el-table-column prop="status" label="路况"> </el-table-column>
        <el-table-column prop="description" label="描述"> </el-table-column>
      </el-table>
    </div>
    <div id="map" v-else>
      <MapContainer></MapContainer>
    </div>
    <div id="btn" @click="change()">
      <el-tooltip content="点击切换" placement="top">
        <el-button icon="el-icon-sort" type="info" circle></el-button>
      </el-tooltip>
    </div>
  </div>
</template>

<script>
import axios from "axios";
// 导入
import MapContainer from "@/views/Map/MapContainer";
export default {
  data() {
    return {
      num: true,
      //   表格数据
      tableData: [],
      loading: true,
    };
  },
  components: {
    MapContainer,
  },
  methods: {
    filterTag(value, row) {
      return row.status === value;
    },
    change() {
      this.num = !this.num;
    },
  },
  async created() {
    const res = await axios({
      method: "GET",
      url: "static/traffic.json",
    });
    //   console.log(res.data);
    this.tableData = res.data;
    this.loading = false;
  },
};
</script>

<style>
#app {
  position: relative;
}

#btn {
  position: absolute;
  bottom: 30px;
  right: 90px;
}

.table {
  margin-top: 10px;
}

.el-row {
  margin-left: 10px;
  margin-top: 20px;
  margin-bottom: 20px;
}
.el-row:last-child {
  margin-bottom: 0;
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  /* background: #d3dce6; */
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.addbtn {
  margin-top: 12px;
  margin-left: 15px;
}
</style>
